<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="Model.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<script type="text/javascript">
function sbmit1(){    
		var SelectionMemberID = document.getElementById("SelectionMemberID").value;
	    var SelectionCurriculumID = document.getElementById("SelectionCurriculumID").value;	    
	    var SelectionID =  document.getElementById("SelectionID").value;
	    var SelectionState = true;
	    var url = "../selectionservlet";
	    var postParam = "SelectionMemberID=" + SelectionMemberID + "&SelectionCurriculumID=" + SelectionCurriculumID 
	    + "&SelectionID=" + SelectionID + "&SelectionState=" + SelectionState + "&opType=addSelection";
	    var ajax = false;
// 	     alert(postParam);
	    if (window.XMLHttpRequest){
	        ajax = new XMLHttpRequest();
	        if (ajax.overrideMimeType) {
	            ajax.overrideMimeType("text/xml");
	        }
	    }else if (window.ActiveXObject){
	        try{
	            ajax = new ActiveXObject("Msxml2.XMLHTTP");
	        }catch(e){
	            try{
	                ajax = new ActiveXObject("Microsoft.XMLHTTP");
	            }catch (e){;}
	        }
	    }
	    if (!ajax) {
	        window.alert("不能创建XMLHttpRequest对象实例.");            
	        return false;
	    }
	    ajax.open("POST", url, true);
	    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    ajax.send(postParam);    
	   	
	    ajax.onreadystatechange = function() {        	      
	    	if(ajax.readyState==4){
	    		if(ajax.responseText==1){
	    			alert("添加成功！");    			
	    		}
	    		else{
	    			alert("添加失败！");
	    		}	    		        	
	    	}			
	    }	
}
function sbmit2(){    
	var SelectionMemberID = document.getElementById("SelectionMemberID").value;
    var SelectionCurriculumID = document.getElementById("SelectionCurriculumID").value;	    
    var SelectionID =  document.getElementById("SelectionID").value;
    var SelectionState = false;
    var url = "../selectionservlet";
    var postParam = "SelectionMemberID=" + SelectionMemberID + "&SelectionCurriculumID=" + SelectionCurriculumID 
    + "&SelectionID=" + SelectionID + "&SelectionState=" + SelectionState + "&opType=addSelection";
    var ajax = false;
// 	     alert(postParam);
    if (window.XMLHttpRequest){
        ajax = new XMLHttpRequest();
        if (ajax.overrideMimeType) {
            ajax.overrideMimeType("text/xml");
        }
    }else if (window.ActiveXObject){
        try{
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            }catch (e){;}
        }
    }
    if (!ajax) {
        window.alert("不能创建XMLHttpRequest对象实例.");            
        return false;
    }
    ajax.open("POST", url, true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.send(postParam);    
   	
    ajax.onreadystatechange = function() {        	      
    	if(ajax.readyState==4){
    		if(ajax.responseText==1){
    			alert("添加成功！");    			
    		}
    		else{
    			alert("添加失败！");
    		}	    		        	
    	}			
    }	
}
</script>
</head>
<body>
<div align="center">
<!-- 代码仅作测试后台功能用，具体业务实现当根据需求详改。 -->
		<form method="get" name="regform" action=".">
				<tr>
					<td align="right" height="60"><p>当前操作ID</p></td>
					<td align="left"><input id="SelectionID"
						name="SelectionID" type="text" value=""></td>
							
					<td align="right" height="60"><p>所选课ID</p></td>
					<td align="left"><input id="SelectionMemberID"
						name="SelectionMemberID" type="text" value=""></td>
						
					<td align="right" height="60"><p>会员ID</p></td>
					<td align="left"><input id="SelectionCurriculumID"
						name="SelectionCurriculumID" type="text" value=""></td>
						
					<td align="center" height="60">&nbsp;</td>
					<td align="left" height="60">
					<input id="reserve" name="reserve" type="button" value="预定" onclick="sbmit1()"></td>
					<td align="center" height="60">&nbsp;</td>
					<td align="left" height="60">
					<input id="cancel" name="cancel" type="button" value="取消预定" onclick="sbmit2()"></td>
				</tr>
			</form>
			</div>
</body>
</html>

